<?php
class b_question_choice
{
    public function get_choice_by_question($question_id){
        global $DB;
        
        $choice = $DB->get_records('b_question_choice', array('id_question'=>$question_id));
        
        return $choice; 
    }
    
    public function update_choice($choice_info) 
	{
		global $DB;
		$DB->update_record('b_question_choice', $choice_info);
	}
    
    public function delete_choice($choice_id)
    {
        global $DB;
        $DB->delete_records('b_question_choice', array('id'=>$choice_id));
    }
    
    public function delete_choice_by_questionID($question_id)
    {
        global $DB;
        $DB->delete_records('b_question_choice', array('id_question'=>$question_id));
    }
    
    public function add_choices($question_id, $ques_choice)
    {
        global $DB;
        $n = count($ques_choice);
        for($i=0; $i< $n; $i++){
            $choice['id_question'] = $question_id;
            $choice['content'] = $ques_choice[$i];
            $DB->insert_record('b_question_choice', $choice);
        }
    }
}
?>
